package com.aw.puzzle.dropboxdiet;

/**
 * User: gmc
 * Date: 29/01/11
 */
public class Activity implements Comparable<Activity> {
    private String name;
    private int calorieValue;
    private int absValue;

    public Activity(String name, int calorieValue) {
        this.name = name;
        setCalorieValue(calorieValue);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getCalorieValue() {
        return calorieValue;
    }

    public void setCalorieValue(int calorieValue) {
        this.calorieValue = calorieValue;
        setAbsValue(calorieValue);
    }

    public int compareTo(Activity o) {
        return this.getAbsValue() - o.getAbsValue();
    }

    public int getAbsValue() {
        return absValue;
    }

    public void setAbsValue(int absValue) {
        this.absValue = Math.abs(absValue);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Activity)) return false;

        Activity activity = (Activity) o;

        if (name != null ? !name.equals(activity.name) : activity.name != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return name != null ? name.hashCode() : 0;
    }
}
